home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / extension.c < prev    next >
C/C++ Source or Header  |  1994-02-25  |  2KB  |  84 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record
  3.  * Copyright (C) 1993 by Charles Sandmann (sandmann@clio.rice.edu)
  4.  * 
  5.  * This file is part of ED.
  6.  * 
  7.  * ED is free software; you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation.
  9.  * 
  10.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  11.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  13.  * 
  14.  * You should have received a copy of the GNU General Public License along with ED
  15.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  16.  * Mass Ave, Cambridge, MA 02139, USA.
  17.  */
  18. #include "opsys.h"
  19.  
  20. #include <string.h>
  21.  
  22. /******************************************************************************\
  23. |Routine: extension
  24. |Callby: load_file output_file
  25. |Purpose: Returns the address of a file's extension, or NULL if it has no
  26. |         extension. This is opsys-sensitive.
  27. |Arguments:
  28. |    file is the file name being analyzed.
  29. \******************************************************************************/
  30. Char *extension(file)
  31. Char *file;
  32. {
  33.     register Char *c,v;
  34.  
  35.     c = file + strlen(file);
  36.     while(c != file)
  37.     {
  38.         if((v = *--c) == '.')
  39.             return(c);
  40. #ifdef VMS
  41.         if(v == ']' || v == '>' || v == ':')
  42. #else
  43. #ifdef GNUDOS
  44.         if(v == '/' || v == '\\')
  45. #else
  46.         if(v == '/')
  47. #endif
  48. #endif
  49.             return(0);
  50.     }
  51.     return(0);
  52. }
  53.  
  54. /******************************************************************************\
  55. |Routine: filename
  56. |Callby: cfg command help load_file store_param
  57. |Purpose: Returns the address of a file's name. This is opsys-sensitive.
  58. |Arguments:
  59. |    file is the file name being analyzed.
  60. \******************************************************************************/
  61. Char *filename(file)
  62. Char *file;
  63. {
  64.     register Char *c,v;
  65.  
  66.     c = file + strlen(file);
  67.     while(c != file)
  68.     {
  69.         v = *--c;
  70. #ifdef VMS
  71.         if(v == ']' || v == '>' || v == ':')
  72. #else
  73. #ifdef GNUDOS
  74.         if(v == '/' || v == '\\' || v == ':')    /* CWS 11-93 (DOS) */
  75. #else
  76.         if(v == '/')
  77. #endif
  78. #endif
  79.             return(++c);
  80.     }
  81.     return(file);
  82. }
  83.  
  84.